package common.config.datasource.sharding.config;

import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;

import java.util.Properties;

/**
 * ShardingSphere算法工具类
 *
 * @author 米泽鹏
 * @since 2023-7-29 下午 7:07
 */
public class ShardingSphereAlgorithmUtil {

	public static ShardingSphereAlgorithmConfiguration buildInlineAlgorithmConfiguration(String algorithmExpression) {
		Properties properties = new Properties();
		properties.setProperty("algorithm-expression", algorithmExpression);
		return new ShardingSphereAlgorithmConfiguration("INLINE", properties);
	}

	public static ShardingSphereAlgorithmConfiguration buildHashModAlgorithmConfiguration(String shardingCount) {
		Properties properties = new Properties();
		properties.setProperty("sharding-count", shardingCount);
		return new ShardingSphereAlgorithmConfiguration("HASH_MOD", properties);
	}

}
